//
//  ContrastDingTableHeaderView.swift
//  QMContrastTableView
//
//  Created by 戴泉明 on 2021/4/25.
//

import Foundation
import UIKit

class ContrastDingTableHeaderView: UIView {
    func setdatas(datas:[ContrastModel]) {
        for item in subviews {
            if item.isKind(of: CompareRightHeader.self) || item.isKind(of: CompareDingHeader.self) || item.isKind(of: CompareAddHeader.self) {
                item.removeFromSuperview()
            }
        }
        
        for (i,item) in datas.enumerated() {
            if i == 0 {
                let header = CompareDingHeader.create()
                header.frame = CGRect(x: CONTRAST_ITEM_WIDTH * CGFloat(i), y: 0, width: CONTRAST_ITEM_WIDTH, height: CONTRAST_HEADER_HEIGHT)
                header.titleLabel.text = item.specName
                header.cancleDingBlock = {() in
                    NotificationCenter.default.post(name: NSNotification.Name(rawValue:"cancleDingContrastNotification"), object: nil, userInfo: ["index":i])
                }
                self.addSubview(header)
            }
        }
    }
}


